package com.example.net

import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import okhttp3.OkHttpClient
import retrofit2.Retrofit
import javax.inject.Singleton

@Module//声明当前是一个Hilt模块
@InstallIn(SingletonComponent::class)//声明当前类的作用域
object HttpHiltModel{
    @HttpClientAnnotation
    @Provides//声明提供
    @Singleton//声明单例
    fun providerOkHttpClient():OkHttpClient{
        return ClientManager.createOkHttpClient()
    }
    @HttpsClientAnnotation
    @Provides//声明提供
    @Singleton//声明单例
    fun providerOkHttpsClient():OkHttpClient{
        return ClientManager.createOkHttpsClient()
    }
    @HttpRetrofitAnnotation
    @Provides//声明提供
    @Singleton//声明单例
    fun providerOkHttpRetrofit(@HttpClientAnnotation client:OkHttpClient):Retrofit{
        return RetrofitManager.getRetrofit(client)
    }
    @HttpsRetrofitAnnotation
    @Provides//声明提供
    @Singleton//声明单例
    fun providerOkHttpsRetrofit(@HttpsClientAnnotation client:OkHttpClient):Retrofit{
        return RetrofitManager.getRetrofit(client)
    }
}